﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Resources;
using System.Reflection;
using System.Globalization;
using BusinessConfiguration;

namespace Language
{
    public class LanguageService
    {
        private static readonly ResourceManager resourceManager =
            new ResourceManager("csla4skeleton.Library.Localization.Resources",
                                Assembly.GetExecutingAssembly());

        private static CultureInfo culture = new CultureInfo(Configuration.CultureInfo);

        public static string GetValidationMessage(string nameOfMessage)
        {
            try
            {
                string message = resourceManager.GetString(nameOfMessage, culture);
                if (message == null)
                    message = "";
                return message;
            }
            catch (Exception ex) 
            {
                return ex.Message;
            }
        }

        public static string GetAuthorizationMessage(string nameOfMessage)
        {
            try
            {
                string message = resourceManager.GetString(nameOfMessage, culture);
                if (message == null)
                    message = "";
                return message;
            }
            catch (Exception ex)
            {
                return ex.Message;
            }
        }
    }   
}
